package com.orange.core.pojo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>ClassName:ShopStatus</p>
 * <p>Description: 品牌商铺枚举</p>
 * <p>Author: lwm</p>
 * <p>Date: 2025/6/26 23:04</p>
 */
@AllArgsConstructor
@Getter
public enum ShopStatus {

    NORMAL(1,"正常"),
    CLOSED(2,"关闭");

    private final Integer code;

    private final String desc;

    private static final Map<Integer,ShopStatus> CODE_TO_MENUM_MAP = Arrays.stream(values())
            .collect(Collectors.toUnmodifiableMap(ShopStatus::getCode, e -> e));

    public static ShopStatus getByCode(Integer code) {
        ShopStatus shopStatus = CODE_TO_MENUM_MAP.get(code);
        if(shopStatus == null){
            throw new IllegalArgumentException("无效的code值：" + code);
        }
        return shopStatus;
    }
}
